home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qscrollview.h.z / qscrollview.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.7 KB  |  134 lines

  1. /****************************************************************************
  2. ** $Id: qscrollview.h,v 2.22 1998/07/03 00:09:53 hanord Exp $
  3. **
  4. ** Definition of QScrollView class
  5. **
  6. ** Created : 970523
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23. #ifndef QVIEWP_H
  24. #define QVIEWP_H
  25.  
  26. #ifndef QT_H
  27. #include "qframe.h"
  28. #include "qscrollbar.h"
  29. #endif // QT_H
  30.  
  31. struct QScrollViewData;
  32.  
  33. class QScrollView : public QFrame
  34. {
  35.     Q_OBJECT
  36. public:
  37.     QScrollView(QWidget *parent=0, const char *name=0, WFlags f=0);
  38.     ~QScrollView();
  39.  
  40.     enum ResizePolicy { Default, Manual, AutoOne };
  41.     virtual void setResizePolicy( ResizePolicy );
  42.     ResizePolicy resizePolicy() const;
  43.  
  44.     void addChild(QWidget* child);
  45.     void removeChild(QWidget* child);
  46.     virtual void addChild(QWidget* child, int x, int y);
  47.     virtual void moveChild(QWidget* child, int x, int y);
  48.     int childX(QWidget* child);
  49.     int childY(QWidget* child);
  50.     bool childIsVisible(QWidget* child);
  51.     void showChild(QWidget* child, bool yes=TRUE);
  52.  
  53.     enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn };
  54.  
  55.     ScrollBarMode vScrollBarMode() const;
  56.     virtual void  setVScrollBarMode( ScrollBarMode );
  57.  
  58.     ScrollBarMode hScrollBarMode() const;
  59.     virtual void  setHScrollBarMode( ScrollBarMode );
  60.  
  61.     QWidget*     cornerWidget() const;
  62.     virtual void setCornerWidget(QWidget*);
  63.  
  64.     QScrollBar*  horizontalScrollBar();
  65.     QScrollBar*  verticalScrollBar();
  66.     QWidget*     viewport();
  67.  
  68.     int        contentsWidth() const;
  69.     int        contentsHeight() const;
  70.     int        contentsX() const;
  71.     int        contentsY() const;
  72.  
  73.     void    resize( int w, int h );
  74.     void    resize( const QSize& );
  75.     void    show();
  76.  
  77. signals:
  78.     void    contentsMoving(int x, int y);
  79.  
  80. public slots:
  81.     virtual void resizeContents( int w, int h );
  82.     void    scrollBy( int dx, int dy );
  83.     void        setContentsPos( int x, int y );
  84.     void    ensureVisible(int x, int y);
  85.     void    ensureVisible(int x, int y, int xmargin, int ymargin);
  86.     void    center(int x, int y);
  87.     void    center(int x, int y, float xmargin, float ymargin);
  88.  
  89.     void    updateScrollBars();
  90.  
  91. protected:
  92.     void    resizeEvent(QResizeEvent*);
  93.     bool    eventFilter( QObject *, QEvent *e );
  94.  
  95.     virtual void viewportPaintEvent( QPaintEvent* );
  96.     virtual void viewportMousePressEvent( QMouseEvent* );
  97.     virtual void viewportMouseReleaseEvent( QMouseEvent* );
  98.     virtual void viewportMouseDoubleClickEvent( QMouseEvent* );
  99.     virtual void viewportMouseMoveEvent( QMouseEvent* );
  100.  
  101.     virtual void drawContentsOffset(QPainter*, int ox, int oy,
  102.             int cx, int cy, int cw, int ch);
  103.     void    frameChanged();
  104.  
  105.     void setMargins(int left, int top, int right, int bottom);
  106.     int leftMargin() const;
  107.     int topMargin() const;
  108.     int rightMargin() const;
  109.     int bottomMargin() const;
  110.  
  111.     bool focusNextPrevChild( bool next );
  112.  
  113. private:
  114.     void moveContents(int x, int y);
  115.  
  116.     QScrollViewData* d;
  117.  
  118. private slots:
  119.     void hslide(int);
  120.     void vslide(int);
  121.  
  122. private:    // Disabled copy constructor and operator=
  123.     QScrollView( const QScrollView & );
  124.     QScrollView &operator=( const QScrollView & );
  125.     void changeFrameRect(const QRect&);
  126. };
  127.  
  128. inline void QScrollView::addChild(QWidget* child)
  129. {
  130.     addChild(child,0,0);
  131. }
  132.  
  133. #endif
  134.